package com.zsrt.java.day20161226.wrl.demo03;

import java.util.Scanner;

public class Work02 {
	
	/**
	 * 输入两个数，当a>b时，把位置互换
	 */
	/*@Test
	public void w02(){
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入第一个数：\n");
		int a = sc.nextInt();
		System.out.println("请输入第二个数：\n");
		int b = sc.nextInt();
		sc.close();
		System.out.println("交换前...");
		System.out.println("a = "+a+"\nb = "+b);	
		System.out.println("-----------------------");
		if(a>b){
			int temp = a;
			a = b;
			b = temp;
		}
		System.out.println("交换后...");
		System.out.println("a = "+a+"\nb = "+b);
	}*/
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入第一个数：");
		int a = sc.nextInt();
		System.out.print("\n请输入第二个数：");
		int b = sc.nextInt();
		sc.close();
		work02(a,b);
	}
	
	/**
	 * 交换参数的值
	 * @param a	参数1
	 * @param b	参数2
	 */
	public static void work02(int a, int b){
		System.out.println("交换前...");
		System.out.println("a = "+a+"\nb = "+b);	
		System.out.println("-----------------------");
		if(a>b){
			int temp = a;
			a = b;
			b = temp;
		}
		System.out.println("交换后...");
		System.out.println("a = "+a+"\nb = "+b);
	}
}
